package com.itheima.dao;

import com.itheima.domain.Permission;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 资 源权限操作类
 */
public interface IPermissionDao {

    /**
     * 根据角色id查询资源信息
     * @param roleId
     * @return
     * @throws Exception
     */
    @Select("select  * from PERMISSION  where  id in (select  PERMISSIONID from ROLE_PERMISSION where  ROLEID = #{roleid})")
    public List<Permission> findPermissionByRoleId(String roleId);

    /**
     * 查询所有资源权限
     * @return
     * @throws Exception
     */
    @Select("select * from PERMISSION")
    public List<Permission> findAll();

    /**
     * 添加资源
     * @param permission
     * @return
     * @throws Exception
     */
    @Insert(" insert into permission(permissionname,url) values(#{permissionName},#{url})")
    public int save(Permission permission);

}
